﻿using System.ComponentModel;
using RaytracerLib.RenderableObjects;

namespace Raytracer.PropertyGridDecorators
{
    public class TriangleObjectProperties : RenderableObjectProperties
    {
        private TriangleObject m_triangle;

        public TriangleObjectProperties(TriangleObject a_triangle) :
            base(a_triangle)
        {
            m_triangle = a_triangle;
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties V1
        {
            get
            {
                return new Vector3Properties(
                    () => m_triangle.V1,
                    (v) => m_triangle.V1 = v); ;
            }
            set
            {
                m_triangle.V1 = value.ToVector3();
            }
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties V2
        {
            get
            {
                return new Vector3Properties(
                    () => m_triangle.V2,
                    (v) => m_triangle.V2 = v); ;
            }
            set
            {
                m_triangle.V2 = value.ToVector3();
            }
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties V3
        {
            get
            {
                return new Vector3Properties(
                    () => m_triangle.V3,
                    (v) => m_triangle.V3 = v); ;
            }
            set
            {
                m_triangle.V3 = value.ToVector3();
            }
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector2Converter))]
        public Vector2Properties T1
        {
            get
            {
                return new Vector2Properties(
                    () => m_triangle.T1,
                    (v) => m_triangle.T1 = v);
            }
            set
            {
                m_triangle.T1 = value.ToVector2();
            }
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector2Converter))]
        public Vector2Properties T2
        {
            get
            {
                return new Vector2Properties(
                    () => m_triangle.T2,
                    (v) => m_triangle.T2 = v);
            }
            set
            {
                m_triangle.T2 = value.ToVector2();
            }
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector2Converter))]
        public Vector2Properties T3
        {
            get
            {
                return new Vector2Properties(
                    () => m_triangle.T3,
                    (v) => m_triangle.T3 = v);
            }
            set
            {
                m_triangle.T3 = value.ToVector2();
            }
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties N1
        {
            get
            {
                return new Vector3Properties(
                    () => m_triangle.N1,
                    (v) => m_triangle.N1 = v); ;
            }
            set
            {
                m_triangle.N1 = value.ToVector3();
            }
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties N2
        {
            get
            {
                return new Vector3Properties(
                    () => m_triangle.N2,
                    (v) => m_triangle.N2 = v); ;
            }
            set
            {
                m_triangle.N2 = value.ToVector3();
            }
        }

        [Category(Categories.TRIANGLE)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties N3
        {
            get
            {
                return new Vector3Properties(
                    () => m_triangle.N2,
                    (v) => m_triangle.N2 = v); ;
            }
            set
            {
                m_triangle.N2 = value.ToVector3();
            }
        }
    }
}